home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / mint104s.zoo / mint.src / inline.h < prev    next >
C/C++ Source or Header  |  1993-03-08  |  2KB  |  85 lines

  1. /*
  2. Copyright 1992 Eric R. Smith.
  3. All rights reserved.
  4.  */
  5.  
  6. /*
  7.  * inlining of various utility functions, for speed
  8.  * NOTE: ALL functions in this file must also have
  9.  * "normal" equivalents in the .c or .s files;
  10.  * don't put a function just into here!
  11.  */
  12.  
  13. #ifdef __GNUC__
  14.  
  15. #define spl7()            \
  16. ({  register short retvalue;    \
  17.     __asm__ volatile("        \
  18.     movew sr,%0;         \
  19.     oriw  #0x0700,sr "     \
  20.     : "=d"(retvalue)         \
  21.     ); retvalue; })
  22.  
  23. #define spl(N)            \
  24. ({                  \
  25.     __asm__ volatile("        \
  26.     movew %0,sr "         \
  27.     :                \
  28.     : "d"(N) ); })
  29.  
  30.  
  31. /*
  32.  * note that we must save some registers ourselves,
  33.  * or else gcc will run out of reggies to use
  34.  * and complain
  35.  */
  36.  
  37. #define callout1(func, a)            \
  38. ({                        \
  39.     register long retvalue __asm__("d0");    \
  40.     long _f = func;                \
  41.     short _a = (short)(a);            \
  42.                         \
  43.     __asm__ volatile            \
  44.     ("  moveml d5-d7/a4-a6,sp@-;        \
  45.         movew %2,sp@-;            \
  46.         jsr %1@;                \
  47.         addqw #2,sp;            \
  48.         moveml sp@+,d5-d7/a4-a6 "        \
  49.     : "=r"(retvalue)    /* outputs */    \
  50.     : "a"(_f), "r"(_a)    /* inputs */    \
  51.     : "d0", "d1", "d2", "d3", "d4",        \
  52.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  53.     );                    \
  54.     retvalue;                \
  55. })
  56.  
  57. #define callout2(func, a, b)            \
  58. ({                        \
  59.     register long retvalue __asm__("d0");    \
  60.     long _f = func;                \
  61.     short _a = (short)(a);            \
  62.     short _b = (short)(b);            \
  63.                         \
  64.     __asm__ volatile            \
  65.     ("  moveml d5-d7/a4-a6,sp@-;        \
  66.         movew %3,sp@-;            \
  67.         movew %2,sp@-;            \
  68.         jsr %1@;                \
  69.         addqw #4,sp;            \
  70.         moveml sp@+,d5-d7/a4-a6 "        \
  71.     : "=r"(retvalue)    /* outputs */    \
  72.     : "a"(_f), "r"(_a), "r"(_b) /* inputs */ \
  73.     : "d0", "d1", "d2", "d3", "d4",        \
  74.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  75.     );                    \
  76.     retvalue;                \
  77. })
  78.  
  79. #endif
  80.  
  81. #ifdef LATTICE
  82. #pragma inline d0=spl7()    {"40c0007c0700";}
  83. #pragma inline d0=spl(d0)    {"46c0";}
  84. #endif
  85.